package jetgege.com.jetpreventviolence;

import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.view.View;

/**
 * Created by Mr.Left on 2017/7/20.
 */

public class JETPreventViolence {
    public static final int SHORT_TIME = 500;
    public static final int LONG_TIME = 1000;
    public static final int LONGER_TIME = 2000;

    public JETPreventViolence() {
    }

    public static void preventClick(Context c, final View v, int timeMs) {
        Log.d("view is able= ", String.valueOf(v.isEnabled()));
        v.setEnabled(false);
        v.setClickable(false);
        Log.d("view is able= ", String.valueOf(v.isEnabled()));
        (new Handler(c.getMainLooper())).postDelayed(new Runnable() {
            public void run() {
                v.setEnabled(true);
                v.setClickable(true);
            }
        }, (long)timeMs);

    }
}
